import * as types from "./mutation-types";
import Api from "api/api";

const state = {
  currentSetting: {}
};

const getters = {
  currentSetting: state => state.currentSetting
};

const actions = {
  getSettingS({ commit }, param) {
    return Api.getSetting(param).then(ret => {
      commit(types.UPDATE_CURSETTING, ret.data.data);
      return ret;
    });
  },

  addOrUpdateAppImageS({ commit }, param) {
    return Api.addOrUpdateAppImage(param).then(ret => {
      return ret;
    });
  },
  addOrUpdateTrainSettingS({ commit }, param) {
    return Api.addOrUpdateTrainSetting(param).then(ret => {
      return ret;
    });
  },
  addOrUpdateHallSettingS({ commit }, param) {
    return Api.addOrUpdateHallSetting(param).then(ret => {
      return ret;
    });
  },
  addOrUpdateH5VersionS({ commit }, param) {
    return Api.addOrUpdateH5Version(param).then(ret => {
      return ret;
    });
  },
  addOrUpdateAppSettingS({ commit }, param) {
    return Api.addOrUpdateAppSetting(param).then(ret => {
      return ret;
    });
  },
  addOrUpdateAboutSettingS({ commit }, param) {
    return Api.addOrUpdateAboutSetting(param).then(ret => {
      return ret;
    });
  },
  addOrUpdateInstrSettingS({ commit }, param) {
    return Api.addOrUpdateInstrSetting(param).then(ret => {
      return ret;
    });
  }
};

const mutations = {
  [types.UPDATE_CURSETTING](state, payload) {
    state.currentSetting = payload;
  }
};

export default {
  state,
  getters,
  actions,
  mutations
};
